package aspect;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAspectBySpring {
	private Log log=LogFactory.getLog(LogAspectBySpring.class);
	private final String POINT_CUT="execution(* service.WorkServic.work(..))";
	@Before(value=POINT_CUT)
	public void logBefore() {
		log.info("log before.....");
	}
	@Around(value=POINT_CUT)
	public Object logAroud(ProceedingJoinPoint point) {
		Object obj=null;
		log.info("log before in around.....");
		try {
			String arg=(String)point.getArgs()[0];
			obj=point.proceed(new Object[] {arg.toUpperCase()});
		} catch (Throwable e) {
			e.printStackTrace();
		}
		log.info("log after in around.....");
		return obj;
	}
	
	
}
